package com.lgh.hotel.controller;

import com.lgh.hotel.common.aop.LogAnnotation;
import com.lgh.hotel.dao.pojo.Guest;
import com.lgh.hotel.service.GuestService;
import com.lgh.hotel.vo.Result;
import com.lgh.hotel.vo.params.GuestParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "客人模块")
@RestController
@RequestMapping("guest")
public class GuestController {

    @Autowired
    GuestService guestService;

    @ApiOperation(value = "获取所有入住客人信息")
    @GetMapping
    public Result findAll(){
        return guestService.findAll();
    }

    @ApiOperation(value = "获取单个用户信息")
    @GetMapping("/find/guest/{idCard}")
    public Result findGuestId(@PathVariable("idCard") Long idCard){
        return Result.succ(guestService.findGuestById(idCard));
    }

    @LogAnnotation
    @ApiOperation("增加客人")
    @PostMapping("/addGuest")
    public Result addGuest(@RequestBody Guest guest){
        return guestService.addGuest(guest);
    }

    @LogAnnotation
    @ApiOperation("删除客人")
    @DeleteMapping("/deleteGuest")
    public Result deleteGuest(@RequestBody Guest guest){
        return guestService.deleteGuest(guest.getIdCard());
    }

    @LogAnnotation
    @ApiOperation("更新客人")
    @PutMapping("/updateGuest")
    public Result updateGuest(@RequestBody Guest guest){
        return guestService.updateGuest(guest);
    }


    @LogAnnotation
    @ApiOperation("登录客人")
    @PostMapping("/login")
    public Result login(@RequestBody GuestParams guestParams){
        return guestService.login(guestParams);
    }


}
